package study.java.jdk.jdk8._1_stream.intermediate;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 截断流，使元素不超过给定数量
 */
@Slf4j
public class limit_Test {

    @Test
    public void test1() {
        List<String> src = Arrays.asList("s2_switch", "efg", "123", "s2_switch");
        List<String> dest = src.stream()
                .limit(2)
                .collect(Collectors.toList());
        log.info("{}", dest);
    }
}
